import {fetch} from 'utils/fetch';


function  escape2Html(str) {
  var arrEntities={'lt':'<','gt':'>','nbsp':' ','amp':'&','quot':'"'};
  return str.replace(/&(lt|gt|nbsp|amp|quot);/ig,function(all,t){return arrEntities[t];});
}

/***
 * 获取注册协议
 * @returns {*}
 */
export function agreement(code) {

  return new Promise((resolve, reject) => {
    fetch({
      url: 'cms/agreement/'+code,
      method: 'post'
    }).then(response => {
      if (response.code === 200) {
        sessionStorage.setItem("updateTitle",response.data.title);
        resolve(escape2Html(response.data.contentData));
      }
    }).catch(error => {
      reject(error);
    });
  });

}
